﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.HVAC.Properties;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class LaySprinklersMidForm : System.Windows.Forms.Form
	{
		public LaySprinklersMidForm(HVACUserSetting userSetting)
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			this.userSettingS = userSetting;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.hytbRowCount.Text.Trim() == "" || this.hytbColCount.Text.Trim() == "" || this.hytbTopDistance.Text.Trim() == "" || this.hytbBottomDistance.Text.Trim() == "" || this.hytbLeftDistance.Text.Trim() == "" || this.hytbRightDistance.Text.Trim() == "")
			{
				MessageBox.Show("所有参数均不能为空", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			this.layMidParameter.RowCount = Convert.ToInt32(this.hytbRowCount.Text.Trim());
			this.layMidParameter.ColCount = Convert.ToInt32(this.hytbColCount.Text.Trim());
			this.layMidParameter.TopDistance = Convert.ToDouble(this.hytbTopDistance.Text.Trim());
			this.layMidParameter.BottomDistance = Convert.ToDouble(this.hytbBottomDistance.Text.Trim());
			this.layMidParameter.LeftDistance = Convert.ToDouble(this.hytbLeftDistance.Text.Trim());
			this.layMidParameter.RightDistance = Convert.ToDouble(this.hytbRightDistance.Text.Trim());
			this.LaySettingWrite();
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void LayAirTerminalAreaForm_Load(object sender, EventArgs e)
		{
			this.LaySettingInit();
		}

		private void LaySettingInit()
		{
			this.layMidParameter = this.userSettingS.GetLaySprinklersMid();
			this.hytbRowCount.Text = this.layMidParameter.RowCount.ToString();
			this.hytbColCount.Text = this.layMidParameter.ColCount.ToString();
			this.hytbTopDistance.Text = this.layMidParameter.TopDistance.ToString();
			this.hytbBottomDistance.Text = this.layMidParameter.BottomDistance.ToString();
			this.hytbLeftDistance.Text = this.layMidParameter.LeftDistance.ToString();
			this.hytbRightDistance.Text = this.layMidParameter.RightDistance.ToString();
		}

		private void LaySettingWrite()
		{
			this.userSettingS.WriteLaySprinklersMid(this.layMidParameter);
		}

		private HVACUserSetting userSettingS;

		public LayMidParameter layMidParameter = new LayMidParameter();
	}
}
